export const rules = {
  name: [{ required: true }],
  price: [
    { required: true },
    {
      validator: (val: any) => {
        const regex = /^[+-]?\d+(\.\d+)?$/
        if (!regex.test(val.toString().replace(/"/g, ''))) {
          return { result: false, message: '请输入数字', type: 'error' }
        }
        if (Number(val) === 0) {
          return { result: false, message: '价格不能为0', type: 'error' }
        }
        return { result: true }
      }
    }
  ],
  downloadUrl: [{ required: true }],
  imageUrl: [{ required: true }],
  status: [{ required: true }],
  cycle: [
    {
      required: true
    },
    {
      validator: (val: string | number) => {
        const regex = /^[0-9]+$/
        if (!regex.test(val.toString().replace(/^"|"$/g, ''))) {
          return { result: false, message: '请输入整数', type: 'error' }
        }
        return { result: true }
      }
    }
  ],
  description: [{ required: true }]
}
